﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using WineBLL;
using System.Data;
using AdminModel;




namespace WineService
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“Service1”。
    // 注意: 为了启动 WCF 测试客户端以测试此服务，请在解决方案资源管理器中选择 Service1.svc 或 Service1.svc.cs，然后开始调试。
    public class Service1 : IService1
    {
        MessageBLL helper = new MessageBLL();
        #region 通过sql语句操作数据库
        public string GetTable(string sql)
        {
            return helper.GetTable(sql);
        }
        public int ExcNonquery(string sql)
        {
            return helper.ExcNonquery(sql);
        }
        #endregion

        #region 管理员表
        /// <summary>
        /// 显示管理员表
        /// </summary>
        /// <returns></returns>
        public string GetAdmins1()
        {
            string str = "select AdminsID,AdminsRoleID,AdminsNumber,AdminsPwd,AdminsTel,AdminsEmail,AdminDate,AdminStart from Admins";
            return helper.GetAdmins(str);
        }
        /// <summary>
        /// 管理员登陆验证
        /// </summary>
        /// <param name="AdminName"></param>
        /// <param name="AdminPwd"></param>
        /// <returns></returns>
        public string GetAdmins2(string AdminName,string AdminPwd)
        {
            string str = "select AdminsID,AdminsRoleID,AdminsNumber,AdminsPwd,AdminsTel,AdminsEmail,AdminDate,AdminStart from Admins where AdminsNumber='" + AdminName + "' and AdminsPwd='" + AdminPwd + "' and AdminStart=1";
            return helper.SelectAdmins(str);
        }
        /// <summary>
        /// 修改管理员信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateAdmins2(Admins admin)
        {
            string sql = "update Admins set AdminsNumber='" + admin.AdminsNumber + "',AdminsPwd='" + admin.AdminsPwd + "',AdminsRoleID=" + admin.AdminsRole + ",AdminsTel='" + admin.AdminsTel + "',AdminsEmail='" + admin.AdminsEmail + "',AdminDate='" + admin.AdminDate + "',AdminStart=" + admin.AdminStart + " where AdminsID=" + admin.AdminsID + "";
            return helper.UpdateAdmins(sql);
        }
        /// <summary>
        /// 添加管理员信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddAdmins1(Admins admin)
        {
            string str = string.Format("insert into Admins(AdminsNumber,AdminsPwd,AdminsRoleID,AdminsTel,AdminsEmail,AdminDate,AdminStart)values('{0}','{1}',{2},'{3}','{4}','{5}',{6})", admin.AdminsNumber, admin.AdminsPwd, admin.AdminsRoleID, admin.AdminsTel, admin.AdminsEmail, admin.AdminDate, admin.AdminStart);
            return helper.AddAdmins(str);
        }
        /// <summary>
        /// 删除管理员信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteAdmins(int id)
        {
            string str = "delete from Admins where AdminsID in(" + id + ")";
            return helper.DeleteAdmins(str);
        }

        #endregion

        #region 管理员角色权限
        /// <summary>
        /// 显示管理员角色权限
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetAdminsPower()
        {
            string str = "select AdminsPowerID,AdminsPowerName,AdminsPowerWay from AdminsPowers";
            return helper.GetAdminsPower(str);
        }
        /// <summary>
        /// 搜索管理员角色权限
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string SelectAdminsPower(string name)
        {
            string str = "select AdminsPowerID,AdminsPowerName,AdminsPowerWay from AdminsPowers where AdminsPowerName='" + name + "'";
            return helper.SelectAdminsPower(str);
        }

        /// <summary>
        /// 根据编号获取管理员角色权限ID
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetidAdminsPower(int id)
        {
            string str = "select AdminsPowerID,AdminsPowerName,AdminsPowerWay from AdminsPowers where AdminsPowerID=" + id + "";
            return helper.GetidAdminsPower(str);
        }
        /// <summary>
        /// 修改管理员角色权限
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateAdminsPower(AdminsPower admin)
        {
            string str = "update AdminsPowers set AdminsPowerName='" + admin.AdminsPowerName + "',AdminsPowerWay=" + admin.AdminsPowerWay + " where AdminsPowerID=" + admin.AdminsPowerID + "";
            return helper.UpdateAdminsPower(str);
        }
        /// <summary>
        /// 添加管理员角色权限
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddAdminsPower(AdminsPower admin)
        {
            string str = string.Format("insert into AdminsPowers(AdminsPowerName,AdminsPowerWay)values('{0}',{1})",admin.AdminsPowerName,admin.AdminsPowerWay);
            return helper.AddAdminsPower(str);
        }
        /// <summary>
        /// 删除管理员角色权限
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteAdminsPower(int id)
        {
            string str = "delete from AdminsPowers where AdminsPowerID in(" + id + ")";
            return helper.DeleteAdminsPower(str);
        }
        #endregion

        #region 管理员角色表
        /// <summary>
        /// 管理员角色表显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetAdminRole()
        {
            string str = "select AdminsRoleID,AdminsRoleName from AdminsRoles";
            return helper.GetAdminRole(str);
        }
        /// <summary>
        /// 删除管理员角色
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteAdminRole(int  id)
        {
            string str = "delete from AdminsRoles where AdminsRoleID in(" + id + ")";
            return helper.DeleteAdminRole(str);
        }
        /// <summary>
        /// 添加管理员角色
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddAdminRole(AdminsRole admin)
        {
            string str = "insert into AdminsRoles(AdminsRoleName)values('" + admin.AdminsRoleName + "')";
            return helper.AddAdminRole(str);
        }
        /// <summary>
        /// 搜索管理员角色
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string SelectAdminRole(string name)
        {
            string str = "select AdminsRoleID,AdminsRoleName from AdminsRoles where AdminsRoleName='" + name + "'";
            return helper.SelectAdminRole(str);
        }
        /// <summary>
        /// 根据编号获取管理员角色
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetidAdminRole(string str)
        {
            return helper.GetidAdminRole(str);
        }
        /// <summary>
        /// 修改管理员角色信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateAdminRole(AdminsRole admin)
        {
            string str = "update AdminsRoles set AdminsRoleName='" + admin.AdminsRoleName + "' where AdminsRoleID=" + admin.AdminsRoleID + "";
            return helper.UpdateAdminRole(str);
        }
        #endregion

        #region 地区信息
        /// <summary>
        /// 地区信息显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetArea()
        {
            string str = "select AreaID,AreaName,UpperStory from Areas";
            return helper.GetArea(str);
        }
        
        /// <summary>
        /// 修改地区信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateArea(Area aa)
        {
            string str = "update Areas set AreaName='" + aa.AreaName + "',UpperStory=" + aa.UpperStory + " where AreaID=" + aa.AreaID + "";
            return helper.UpdateArea(str);
        }
        /// <summary>
        ///添加地区信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddArea(Area aa)
        {
            string str = "insert into Areas(AreaName,UpperStory)values('" + aa.AreaName + "','" + aa.UpperStory + "')";
            return helper.AddArea(str);
        }
        /// <summary>
        /// 删除地区信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteArea(int  id)
        {
            string str = "delete from Areas where AreaID in(" + id + ")";
            return helper.DeleteArea(str);
        }
        #endregion

        #region 收藏表
        /// <summary>
        /// 显示收藏表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetCikkect()
        {
            string str = "select CollectID,GoodsID,UsersID from Cikkects";
            return helper.GetCikkect(str);
        }
        /// <summary>
        /// 搜索收藏表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string SelectCikkect(string str)
        {
            return helper.SelectCikkect(str);
        }
        /// <summary>
        /// 根据编号获取收藏表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetidCikkect(string str)
        {
            return helper.GetidCikkect(str);
        }
        /// <summary>
        /// 修改收藏表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateCikkect(Cikkect cc)
        {
            string str = "update Cikkects set GoodsID=" + cc.GoodsID + ",UsersID=" + cc.UsersID + " where CollectID=" + cc.CollectID + "";
            return helper.UpdateCikkect(str);
        }
        /// <summary>
        /// 添加收藏表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddCikkect(Cikkect cc)
        {
            string str = "insert into Cikkects(GoodsID,UsersID)values(" + cc.GoodsID + "," + cc.UsersID + ")";
            return helper.AddCikkect(str);
        }
        /// <summary>
        /// 删除收藏表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteCikkect(int id)
        {
            string str = "delete from Cikkects where CollectID in ("+id+")";
            return helper.DeleteCikkect(str);
        }
        #endregion

        #region 评论表
        /// <summary>
        /// 显示评论表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetComment()
        {
            string str = "select CommentID,UsersID,GoodsID,CommentContent,CommentDate,CommentStar,PraiseNum,CommentImg from Comments ";
            return helper.GetComment(str);
        }
        /// <summary>
        /// 搜索评论表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string SelectComment(string str)
        {
            return helper.SelectComment(str);
        }
        /// <summary>
        /// 根据编号获取评论表ID
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetidComment(string str)
        {
            return helper.GetidComment(str);
        }
        /// <summary>
        /// 修改评论表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateComment(Comment cc)
        {
            string str = "update Comments set UsersID=" + cc.UsersID + ",GoodsID='" + cc.GoodsID + "',CommentContent='" + cc.CommentContent + "',CommentDate='" + cc.CommentDate + "',CommentStar='" + cc.CommentStar + "',PraiseNum='"+cc.PraiseNum+"',CommentImg='"+cc.CommentImg+"' where CommentID=" + cc.CommentID + "";
            return helper.UpdateComment(str);
        }
        /// <summary>
        /// 添加评论表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddComment(Comment cc)
        {
            string str = "insert into Comments(UsersID,GoodsID,CommentContent,CommentDate,CommentStar,PraiseNum,CommentImg)values('" + cc.UsersID + "','" + cc.GoodsID + "','" + cc.CommentContent + "','" + cc.CommentDate + "','" + cc.CommentStar + "','" + cc.PraiseNum + "','" + cc.CommentImg + "')";
            return helper.AddComment(str);
        }
        /// <summary>
        /// 删除评论表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteComment(int  id)
        {
            string str = "delete from Comments where CommentID in (" + id + ")";
            return helper.DeleteComment(str);
        }

        #endregion

        #region 用户收货信息
        /// <summary>
        /// 用户收货信息显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetConsignee()
        {

            string str = "select ConsigneeID,ConsigneeName,AreaID,ConsigneeAddr,ConsigneeTel,UsersID from Consignees";
            return helper.GetConsignee(str);
        }
        /// <summary>
        /// 搜索用户收货信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string SelectConsignee(string str)
        {
            return helper.SelectConsignee(str);
        }
        /// <summary>
        /// 根据编号获取用户收货信息ID
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetidConsignee(string str)
        {
            return helper.GetidConsignee(str);
        }
        /// <summary>
        /// 修改用户收货信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateConsignee(Consignee cc)
        {
            string str = "update Consignees set ConsigneeName='"+cc.ConsigneeName+"',AreaID='"+cc.AreaID+"',ConsigneeAddr='"+cc.ConsigneeAddr+"',ConsigneeTel='"+cc.ConsigneeTel+"',UsersID='"+cc.UsersID+"' where ConsigneeID="+cc.ConsigneeID+"";
            return helper.UpdateConsignee(str);
        }
        /// <summary>
        /// 添加用户收货信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddConsignee(Consignee cc)
        {
            string str = "insert into Consignees(ConsigneeName,AreaID,ConsigneeAddr,ConsigneeTel,UsersID)values('" + cc.ConsigneeName + "','" + cc.AreaID + "','" + cc.ConsigneeAddr + "','" + cc.ConsigneeTel + "','" + cc.UsersID + "')";
            return helper.AddConsignee(str);
        }
        /// <summary>
        /// 删除用户收货信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteConsignee(int id)
        {
            string str = "delete from Consignees where ConsigneeID in ("+id+")";
            return helper.DeleteConsignee(str);
        }
        #endregion

        #region 商品信息表
        /// <summary>
        /// 显示商品信息表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetGoodsMessage()
        {
            string str = "select GoodsID,GoodsName,GoodsWinery,GoodsYear,GoodsAlcohol,GoodsStandard,GoodsVolume,GoodsStock,GoodsProcess,GoodsStore,GoodsPrice,GoodsOdor,GoodsBox,GoodsAddr,GoodsTypeID,GoodsStart,GoodsImg,GoodsNum from GoodsMessages";
            return helper.GetGoodsMessage(str);
        }
        /// <summary>
        /// 搜索管理员商品信息表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string SelectGoodsMessage(string str)
        {
            return helper.SelectGoodsMessage(str);
        }
        /// <summary>
        /// 根据编号获取商品信息表ID
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetidGoodsMessage(string str)
        {
            return helper.GetidGoodsMessage(str);
        }
        /// <summary>
        /// 修改商品信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateGoodsMessage(GoodsMessage gg)
        {
            string str = "update GoodsMessages set GoodsName='"+gg.GoodsName+"',GoodsWinery='"+gg.GoodsWinery+"',GoodsYear='"+gg.GoodsYear+"',GoodsAlcohol='"+gg.GoodsAlcohol+"',GoodsStandard='"+gg.GoodsStandard+"',GoodsVolume='"+gg.GoodsVolume+"',GoodsStock='"+gg.GoodsStock+"',GoodsProcess='"+gg.GoodsProcess+"',GoodsStore='"+gg.GoodsStore+"',GoodsPrice='"+gg.GoodsPrice+"',GoodsOdor='"+gg.GoodsOdor+"',GoodsBox='"+gg.GoodsBox+"',GoodsAddr='"+gg.GoodsAddr+"',GoodsTypeID='"+gg.GoodsTypeID+"',GoodsStart='"+gg.GoodsStart+"',GoodsImg='"+gg.GoodsImg+"',GoodsNum='"+gg.GoodsNum+"' where GoodsID='"+gg.GoodsID+"'";
            return helper.UpdateGoodsMessage(str);
        }
        /// <summary>
        /// 添加商品信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddGoodsMessage(GoodsMessage gg)
        {
            string str = "insert into GoodsMessages (GoodsName,GoodsWinery,GoodsYear,GoodsAlcohol,GoodsStandard,GoodsVolume,GoodsStock,GoodsProcess,GoodsStore,GoodsPrice,GoodsOdor,GoodsBox,GoodsAddr,GoodsTypeID,GoodsStart,GoodsImg,GoodsNum) values ('" + gg.GoodsName + "','" + gg.GoodsWinery + "','" + gg.GoodsYear + "','" + gg.GoodsAlcohol + "','" + gg.GoodsStandard + "','" + gg.GoodsVolume + "','" + gg.GoodsStock + "','" + gg.GoodsProcess + "','" + gg.GoodsStore + "','" + gg.GoodsPrice + "','" + gg.GoodsOdor + "','" + gg.GoodsBox + "','" + gg.GoodsAddr + "','" + gg.GoodsTypeID + "','" + gg.GoodsStart + "','" + gg.GoodsImg + "','" + gg.GoodsNum + "')";
            return helper.AddGoodsMessage(str);
        }
        /// <summary>
        /// 删除商品信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteGoodsMessage(int id)
        {
            string str = "delete from GoodsMessages where GoodsID in(" + id + ")";
            return helper.DeleteGoodsMessage(str);
        }

        #endregion

        #region 商品类别表
        /// <summary>
        /// 显示商品类别表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetGoodsType()
        {
            string str = "select GoodsTypeID,GoodsTypeName from GoodsTypes";
            return helper.GetGoodsType(str);
        }
       
        /// <summary>
        /// 修改商品类别信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateGoodsType(GoodsType type)
        {
            string str = "update GoodsTypes set GoodsTypeName='" + type.GoodsTypeName + "' where GoodsTypeID=" + type.GoodsTypeID + "";
            return helper.UpdateGoodsType(str);
        }
        /// <summary>
        /// 添加商品类别信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddGoodsType(GoodsType type)
        {
            string str = "insert into GoodsTypes(GoodsTypeName) values('" + type.GoodsTypeName + "')";
            return helper.AddGoodsType(str);
        }
        /// <summary>
        /// 删除商品类别信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteGoodsType(int GoodsTypeID)
        {
            string str = "delete from GoodsTypes where GoodsTypeID=" + GoodsTypeID;
            return helper.DeleteGoodsType(str);
        }
        #endregion

        #region 订单从表
        /// <summary>
        /// 显示订单从表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetInd()
        {
            string str = "select IndID,GoodsID,IndNum,IndPrice,IndentID from Inds";
            return helper.GetInd(str);
        }
        
        /// <summary>
        /// 修改订单从表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateInd(Ind ind)
        {
            string str = "update Inds set GoodsID=" + ind.GoodsID + ",IndNum=" + ind.IndNum + ",IndPrice='" + ind.IndPrice + "',IndentID=" + ind.IndentID + " where IndID=" + ind.IndID + "";
            return helper.UpdateInd(str);
        }
        /// <summary>
        /// 添加订单从表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddInd(Ind ind)
        {
            string str = string.Format("insert into Inds(GoodsID,IndNum,IndPrice,IndentID) values({0},{1},'{2}',{3})", ind.GoodsID, ind.IndNum, ind.IndPrice, ind.IndentID);
            return helper.AddInd(str);
        }
        /// <summary>
        /// 删除订单从表信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteInd(int IndID)
        {
            string str = "delete from Inds where IndID=" + IndID;
            return helper.DeleteInd(str);
        }
        #endregion

        #region 订单信息
        /// <summary>
        /// 显示订单信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetIndent()
        {
            string str = "select IndentID,IndentNumbers,IndentStart,IndentPay,IndentDate,UsersID,Indentship,ConsigneeName,AreaID,ConsigneeAddr,ConsigneeTel from Indents";
            return helper.GetIndent(str);
        }
       
        /// <summary>
        /// 修改订单信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateIndent(Indent indent)
        {
            string str = "update Indents set IndentNumbers='" + indent.IndentNumbers + "',IndentStart=" + indent.IndentStart + ",IndentPay=" + indent.IndentPay + ",IndentDate='" + indent.IndentDate + "',UsersID=" + indent.UsersID + ",Indentship=" + indent.Indentship + ",ConsigneeName='" + indent.ConsigneeName + "',AreaID=" + indent.AreaID + ",ConsigneeAddr='" + indent.ConsigneeAddr + "',ConsigneeTel=" + indent.ConsigneeTel + " where IndentID=" + indent.IndentID + "";
            return helper.UpdateIndent(str);
        }
        /// <summary>
        /// 添加订单信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddIndent(Indent indent)
        {
            string str = string.Format("insert into Indents(IndentNumbers,IndentStart,IndentPay,IndentDate,UsersID,Indentship,ConsigneeName,AreaID,ConsigneeAddr,ConsigneeTel)values('{0}',{1},{2},'{3}',{4},{5},'{6}',{7},'{8}',{9})", indent.IndentNumbers, indent.IndentStart, indent.IndentPay, indent.IndentDate, indent.UsersID, indent.Indentship, indent.ConsigneeName, indent.ConsigneeAddr, indent.ConsigneeTel);
            return helper.AddIndent(str);
        }
        /// <summary>
        /// 删除订单信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteIndent(int IndentID)
        {
            string str = "delete from Indents where IndentID=" + IndentID;
            return helper.DeleteIndent(str);
        }
        #endregion

        #region 公告表
        /// <summary>
        /// 公告表显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetNotice()
        {
            string str = "select NoticeID,NoticeTitle,NoticeDate,NoticeContent,NoticeStart from Notices";
            return helper.GetNotice(str);
        }
       
        /// <summary>
        /// 修改公告表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateNotice(Notice notice)
        {
            string str = "update Notices set NoticeTitle='" + notice.NoticeTitle + "',NoticeDate='" + notice.NoticeDate + "',NoticeContent='" + notice.NoticeContent + "',NoticeStart=" + notice.NoticeStart + "  where NoticeID=" + notice.NoticeID + "";
            return helper.UpdateNotice(str);
        }
        /// <summary>
        /// 添加公告表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddNotice(Notice notice)
        {
            string str = string.Format("insert into Notices(NoticeTitle,NoticeDate,NoticeContent,NoticeStart ) values('{0}','{1}','{2}',{3})", notice.NoticeTitle, notice.NoticeDate, notice.NoticeContent, notice.NoticeStart);
            return helper.AddNotice(str);
        }
        /// <summary>
        /// 删除公告表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteNotice(int NoticeID)
        {
            string str = "delete from Notices where NoticeID=" + NoticeID;
            return helper.DeleteNotice(str);
        }
        #endregion

        #region 支付记录表
        /// <summary>
        /// 显示支付记录表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetRecord()
        {
            string str = "select RecordID,RecordNumber,RecordPrice,GoodsID,UsersID,RecordDate from Records";
            return helper.GetRecord(str);
        }
        
        /// <summary>
        /// 修改支付记录信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateRecord(Record record)
        {
            string str = "update	Records set RecordNumber='" + record.RecordNumber + "',RecordPrice='" + record.RecordPrice + "',GoodsID=" + record.GoodsID + ",UsersID=" + record.UsersID + ",RecordDate='" + record.RecordDate + "' where RecordID=" + record.RecordID + "";
            return helper.UpdateRecord(str);
        }
        /// <summary>
        /// 添加支付记录信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddRecord(Record record)
        {
            string str = string.Format("insert into Records(RecordNumber,RecordPrice,GoodsID,UsersID,RecordDate) values('{0}','{1}',{2},{3},'{4}')");
            return helper.AddRecord(str);
        }
        /// <summary>
        /// 删除支付记录信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteRecord(int RecordID)
        {
            string str = "delete from Records where RecordID=" + RecordID;
            return helper.DeleteRecord(str);
        }
        #endregion

        #region 商品退货信息
        /// <summary>
        /// 商品退货信息显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetRenturned()
        {
            string str = "select ReturnedID,IndentID,Reason,ReturnedNum,ReturnedStart from Renturneds";
            return helper.GetRenturned(str);
        }
        
        /// <summary>
        /// 修改商品退货信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateRenturned(Renturned renturned)
        {
            string str = string.Format("update Renturneds set IndentID={0},Reason='{1}',ReturnedNum={2},ReturnedStart={3} where ReturnedID={4}", renturned.IndentID, renturned.Reason, renturned.ReturnedNum, renturned.ReturnedStart, renturned.ReturnedID);
            return helper.UpdateRenturned(str);
        }
        /// <summary>
        /// 添加商品退货信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddRenturned(Renturned renturned)
        {
            string str = "insert into Renturneds(IndentID,Reason,ReturnedNum,ReturnedStart) values(" + renturned.IndentID + ",'" + renturned.Reason + "'," + renturned.ReturnedNum + "," + renturned.ReturnedStart + ")";
            return helper.AddRenturned(str);
        }
        /// <summary>
        /// 删除商品退货信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteRenturned(int ReturnedID)
        {
            string str = "delete from Renturneds where ReturnedID=" + ReturnedID;
            return helper.DeleteRenturned(str);
        }
        #endregion

        #region 管理员角色权限关联表
        /// <summary>
        /// 管理员角色权限关联表显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetRolePower()
        {
            string str = "select RolePowerID,AdminsRoleID,AdminsPowerID from RolePowers";
            return helper.GetRolePower(str); 
        }
        /// <summary>
        /// 添加管理员角色权限关联
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddRolePower(string str)
        {
            return helper.AddRolePower(str);
        }
        /// <summary>
        /// 删除管理员角色权限关联
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteRolePower(int RolePowerID)
        {
            string str = "delete from RolePowers where RolePowerID=" + RolePowerID;
            return helper.DeleteRolePower(str);
        }
        /// <summary>
        /// 修改管理员角色权限关联
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateRolePower(RolePower rolepower)
        {
            string str = string.Format("update RolePowers set AdminsRoleID={0},AdminsPowerID={1} where RolePowerID={2}", rolepower.RolePowerID, rolepower.AdminsPowerID, rolepower.RolePowerID);
            return helper.UpdateRolePower(str);
        }
        #endregion

        #region 购物车信息
        /// <summary>
        /// 购物车信息显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetShop()
        {
            string str = "select ShopID,GoodsID,IndentID,ShopDate from Shops";
            return helper.GetShop(str);
        }
        /// <summary>
        /// 修改购物车信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateShop(Shop shop)
        {
            string str = "update Shops set GoodsID=" + shop.GoodsID + ",IndentID=" + shop.IndentID + ",ShopDate='" + shop.ShopDate + "' where ShopID=" + shop.ShopID + "";
            return helper.UpdateShop(str);
        }
        /// <summary>
        ///添加购物车信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddShop(Shop shop)
        {
            string str = string.Format("insert into Shops(GoodsID,IndentID,ShopDate) values({0},{1},'{2}')", shop.GoodsID, shop.IndentID, shop.ShopDate);
            return helper.AddShop(str);
        }
        /// <summary>
        /// 删除购物车信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DeleteShop(int ShopID)
        {
            string str = "delete from Shops where ShopID=" + ShopID;
            return helper.DeleteShop(str);
        }
        #endregion

        #region 用户信息
        /// <summary>
        /// 用户信息显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetUsers()
        {
            string str = "select UsersID,UsersName,UsersTel,UsersPwd,UsersStart,UsersRoleID from Users";
            return helper.GetUsers(str);
        }
        /// <summary>
        /// 根据编号获取用户信息ID
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetidUsers(int UsersID)
        {
            string str = "select UsersID,UsersName,UsersTel,UsersPwd,UsersStart,UsersRoleID from Users where UsersID='"+UsersID+"'";
            return helper.GetidUsers(str);
        }
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateUsers(Users user)
        {
            string str = "update Users set UsersName='" + user.UsersName + "',UsersTel=" + user.UsersTel + ",UsersPwd=" + user.UsersPwd + ",UsersStart=" + user.UsersStart + ",UsersRoleID=" + user.UsersRoleID + " where UsersID=" + user.UsersID + "";
            return helper.UpdateUsers(str);
        }
        /// <summary>
        /// 添加用户信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddUsers(Users user)
        {
            string str = string.Format("insert into Users(UsersName,UsersTel,UsersPwd,UsersStart,UsersRoleID) values('{0}','{1}','{2}','{3}',{4})", user.UsersName, user.UsersTel, user.UsersPwd, user.UsersStart, user.UsersRoleID);
            return helper.AddUsers(str);
        }
        /// <summary>
        /// 删除用户信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DelectUsers(int UsersID)
        {
            string str = "delete from Users where UsersID=" + UsersID;
            return helper.DelectUsers(str);
        }
        #endregion

        #region 用户角色信息
        /// <summary>
        /// 用户角色信息显示
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string GetUsersRole()
        {
            string str = "select UsersRoleID,UsersRoleName from UsersRoles";
            return helper.GetUsersRole(str);
        }
        /// <summary>
        /// 搜索用户角色信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public string SelectUsersRole(int ID)
        {
            string str = "select UsersRoleID,UsersRoleName from UsersRoles where UsersRoleID='" + ID + "'";
            return helper.SelectUsersRole(str);
        }
        /// <summary>
        /// 修改用户角色信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int UpdateUsersRole(UsersRole role)
        {
            string str = "update UsersRoles set UsersRoleName='" + role.UsersRoleID + "' where UsersRoleID=" + role.UsersRoleName;
            return helper.UpdateUsersRole(str);
        }
        /// <summary>
        /// 添加用户角色信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int AddUsersRole(UsersRole role)
        {
            string str = "insert into UsersRoles(UsersRoleName) values('" + role.UsersRoleName + "')";
            return helper.AddUsersRole(str);
        }
        /// <summary>
        /// 删除用户角色信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int DelectUsersRole(int UsersRoleID)
        {
            string str = "delete from UsersRoles where UsersRoleID=" + UsersRoleID;
            return helper.DelectUsersRole(str);
        }
        #endregion
    }
}
